﻿using Microsoft.AspNetCore.Razor.TagHelpers;

namespace Gentings.AspNetCore.TagHelpers.Bootstraps
{
    /// <summary>
    /// Tab标签头部。
    /// </summary>
    [HtmlTargetElement("gt:tab-header")]
    public class TabHeaderTagHelper : TagHelperBase
    {
        /// <summary>
        /// 大小配置。
        /// </summary>
        public bool Small { get; set; }

        /// <summary>
        /// 是否加边框。
        /// </summary>
        public bool Bordered { get; set; }

        /// <summary>
        /// 访问并呈现当前标签实例。
        /// </summary>
        /// <param name="context">当前HTML标签上下文，包含当前HTML相关信息。</param>
        /// <param name="output">当前标签输出实例，用于呈现标签相关信息。</param>
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var content = await output.GetChildContentAsync();
            output.Process("ul", builder =>
            {
                builder.AddCssClass("nav nav-tabs");
                if (Small)
                    builder.AddCssClass("nav-sm");
                if (Bordered)
                    builder.AddCssClass("bordered");
                builder.AppendHtml(content);
            });
        }
    }
}